# -*- coding:utf8 -*- #
# -----------------------------------------------------------------------------------
# ProjectName:  property-ui-auto-test
# FileName:     instant_bill_project.py
# Author  :     
# Datetime:     2022/9/27 18:41
# Description：项目：即时账单
# -----------------------------------------------------------------------------------
from time import sleep

from page.login_page import LoginPage


class InstantBillProject(LoginPage):
    def instant_bill_setup(self):
        # 点击展开
        self.click('//*[@id="app"]/section/section/aside/div/img')
        sleep(0.5)
        # 点击物业服务
        self.click('//*[@id="app"]/section/section/aside/div/div/ul/li[5]/div')
        sleep(0.3)
        # 点击即时
        self.click('//*[@id="app"]/section/section/aside/div/div/ul/li[5]/ul/li[3]/ul/li')

    # 新增账单类别
    def instant_billType_add(self,billTypename="自动化测试类别"):
        self.instant_bill_setup()
        self.click('//*[@id="app"]/section/section/main/section/section/section/header/div/div/form/div[7]/div/button')
        self.send_keys('//*[@id="app"]/section/section/main/section/section/section/main/div[2]/div/div[2]/form/div[1]/div/div/input',billTypename)
        self.click('//*[@id="app"]/section/section/main/section/section/section/main/div[2]/div/div[2]/form/div[2]/div/button')

    # 新增账单类别
    def instant_billType_del(self, billTypename="自动化测试类别", optPwd=123123):
        self.instant_bill_setup()
        self.click('//*[@id="app"]/section/section/main/section/section/section/header/div/div/form/div[7]/div/button')
        self.click('//*[@id="app"]/section/section/main/section/section/section/main/div[2]/div/div[2]/div/span[1]/i')
        self.send_keys('/html/body/div[2]/div/div[2]/div[2]/div[1]/input',optPwd)
        self.click('/html/body/div[2]/div/div[3]/button[2]')

    # 新增即时账单
    def instant_bill_add(self, billName="自动化测试", billAmount=100, date="2022-09-28", optPwd=123123):
        self.instant_bill_setup()
        # 新建即时账单
        self.click('//*[@id="app"]/section/section/main/section/section/section/header/div/div/form/div[6]/div/button')
        # 账单名称
        self.send_keys(
            '//*[@id="app"]/section/section/main/section/section/section/main/div[2]/div/div[2]/form/div[1]/div/div/input',
            billName)
        # 账单金额
        self.send_keys(
            '//*[@id="app"]/section/section/main/section/section/section/main/div[2]/div/div[2]/form/div[2]/div/div/input',
            billAmount)
        # 费用选择
        self.click(
            '//*[@id="app"]/section/section/main/section/section/section/main/div[2]/div/div[2]/form/div[3]/div/div/div/input')
        sleep(1)
        self.second_location('/html/body/div[3]/div[1]/div[1]/ul', 'li')
        # 到期日
        self.send_keys(
            '//*[@id="app"]/section/section/main/section/section/section/main/div[2]/div/div[2]/form/div[4]/div/div[1]/input',
            date)
        self.click('//*[@id="app"]/section/section/main/section/section/section/main/div[2]/div/div[1]/span')
        # 欠费处理
        self.click(
            '//*[@id="app"]/section/section/main/section/section/section/main/div[2]/div/div[2]/form/div[5]/div/div/label[1]/span[1]/span')
        # 线下支付
        self.click(
            '//*[@id="app"]/section/section/main/section/section/section/main/div[2]/div/div[2]/form/div[6]/div/div/label[1]/span[1]/span')
        # 账单电表
        self.click(
            '//*[@id="app"]/section/section/main/section/section/section/main/div[2]/div/div[2]/form/div[7]/div/div/div[2]/button/span')
        sleep(1)
        self.second_location('//*[@id="pane-first"]/ul','li')
        # 提交
        self.click('/html/body/div[4]/div/div[3]/div/button[2]')
        # 确定
        self.click('//*[@id="app"]/section/section/main/section/section/section/main/div[2]/div/div[3]/span/button[2]')
        # 操作密码
        self.send_keys('/html/body/div[5]/div/div[2]/div[2]/div[1]/input', optPwd)
        # 确定
        self.click('/html/body/div[5]/div/div[3]/button[2]')

    # 删除即时账单
    def instant_bill_del(self,optPwd = 123123):
        self.instant_bill_setup()
        sleep(0.5)
        self.click('//*[@id="app"]/section/section/main/section/section/section/main/div[1]/div[3]/table/tbody/tr[1]/td[9]/div/img[4]')
        self.click('/html/body/div[2]/div/div[3]/button[2]')
        self.send_keys('/html/body/div[2]/div/div[2]/div[2]/div[1]/input',optPwd)
        self.click('/html/body/div[2]/div/div[3]/button[2]')


if __name__ == '__main__':
    ibp = InstantBillProject()
    ibp.login()
    # ibp.instant_billType_add()
    # ibp.instant_bill_add()
    # ibp.instant_bill_del()
    ibp.instant_billType_del()
    sleep(4)
    ibp.quit()
